#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=5e4+5;
int n,m;
char a[Maxn],b[Maxn];
int h[1005][26],g[1005];
int f[50005][1005];
int main(){
	freopen("neck.in","r",stdin);
	freopen("neck.out","w",stdout);
	scanf("%s",a+1);
	n=strlen(a+1);
	scanf("%s",b+1);
	m=strlen(b+1);
	
	
	for(int i=2;i<=m;i++){
		int pre=g[i-1];
		while(pre&&b[pre+1]!=b[i])pre=g[pre];
		if(b[pre+1]==b[i])g[i]=pre+1;
//		printf("g[%d]=%d\n",i,g[i]);
	}
	
	h[0][b[1]-'a']=1;
	for(int i=1;i<=m;i++){
		for(int j=0;j<26;j++){
			int pre=i;
			while(pre&&b[pre+1]-'a'!=j)pre=g[pre];
			if(b[pre+1]-'a'==j)h[i][j]=pre+1;
//			printf("h[%d][%c]=%d\n",i,j+'a',h[i][j]);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			f[i+1][j]=max(f[i+1][j],f[i][j]);
			if(h[j][a[i+1]-'a']!=m)f[i+1][h[j][a[i+1]-'a']]=max(f[i+1][h[j][a[i+1]-'a']],f[i][j]+1);
		}
	}
	int ans=0;
	for(int j=0;j<m;j++)ans=max(ans,f[n][j]);
	printf("%d\n",ans);
	return 0;
}
/*
nezhaheaobing
aobing
*/
